<template>
    <div>
      <div class="header">
        <div class="h-left">
          <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
        </div>
        <div class="h-right">
          <span>位置</span>
        </div>
      </div>
      <!--主图-->
      <div class="More_image">
        <img :src="image" alt="加载失败">
      </div>

      <!--分类-->
      <ul class="fen_ul">
        <li @click="tab(item,index)" v-for="(item,index) in classData" :key="index" :class="con==index?'ctive':''">{{item.name}}{{index==0?'（'+count+'）':''}}</li>
      </ul>

      <!--推荐机构-->
      <p class="ji_p">推荐机构</p>
      <ul class="ji_ul">
        <li @click="menav(item)" v-for="(item,index) in orgData" :key="index">
          <div class="top">
            <img :src="item.avatar" alt="">
            <!--<span>888人已加入学习</span>-->
          </div>
          <div class="bottom">
            <p>{{item.user_login}}</p>
            <p>{{item.signature}}</p>
          </div>
        </li>
      </ul>
    </div>
</template>

<script>
  import * as search from "../../../api/search.js"
    export default {
      name: "MoreOrgan",
      data(){
        return {
          image:'',
          classData:[],
          con:0,
          orgData:[],
          count:''
        }
      },
      beforeMount(){
        //获取舞种列表
        search.danceList().then(res=>{
          console.log('舞种列表',res);
          this.classData = res.data;
          this.count = res.count;
          this.image = res.image;
          //推荐机构全部
          let parms2 = {user_type:2,user_id:this.$store.state.user_id,all:1,dance_id:res.data[0].id};
          search.recommendUser(parms2).then(res=>{
            console.log('推荐机构',res)
            this.orgData = res.data;
          });
        });
      },
      mounted(){
        mui.back = function() {
          window.history.go(-1);
        }
      },
      methods:{
        bac(){
          history.go(-1)
        },
        tab(item,i){
          this.con = i;
          //推荐机构分类
          if (i==0){
            //推荐机构
            let parms2 = {user_type:2,user_id:this.$store.state.user_id,all:1,dance_id:item.id};
            search.recommendUser(parms2).then(res=>{
              console.log('推荐机构全部',res)
              this.orgData = res.data;
            });
          } else{
            let parms2 = {user_type:2,user_id:this.$store.state.user_id,dance_id:item.id};
            search.recommendUser(parms2).then(res=>{
              console.log('推荐机构分类',res)
              this.orgData = res.data;
            });
          }

        },
        menav(item){
          this.$router.push({
            path: '/menav',
            query:{
              id:item.id
            }
          })
        }
      }
    }
</script>

<style scoped>
  .header{
    border-bottom: 1px solid #dcdcdc;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
  }
  .header .h-left img{
    width: 22px;
    vertical-align: bottom;
    margin-right: 30px;
  }
  .header .h-right span{
    font-size: 30px;
  }

  .More_image{
    width: 100%;
    height: 420px;
    background: #dcdcdc;
  }
  .More_image img{
    width: 100%;
    height: 100%;
  }

  .fen_ul{
    padding: 40px 40px 0;
    border-bottom: 2px solid #dcdcdc;
    display: flex;
    flex-wrap: wrap;
  }
  .fen_ul li{
    font-size: 32px;
    margin:0 40px 40px 0;
  }
  .fen_ul .ctive{
    color: #884ca4;
  }

  .ji_p{
    padding: 20px 40px 0;
    font-size: 32px;
  }
  .ji_ul{
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .ji_ul li{
    width: 47%;
    padding-bottom: 30px;
  }
  /*.ji_ul li .top{*/
    /*position: relative;*/
  /*}*/
  .ji_ul li .top img{
    width: 100%;
    height: 180px;
  }
  /*.ji_ul li .top span{*/
    /*position: absolute;*/
    /*bottom: 10px;*/
    /*left: 10px;*/
    /*font-size: 24px;*/
    /*color: #fff;*/
  /*}*/
  .ji_ul li .bottom p:nth-child(1){
    font-size: 28px;
    line-height: 36px;
  }
  .ji_ul li .bottom p:nth-child(2){
    font-size: 24px;
    line-height: 36px;
    color: #8c8c8c;
  }
</style>
